<?php

namespace app\index\controller;

use app\common\controller\Frontend;

class Index extends Frontend
{

    public function index()
    {

//        $queryIP = $this->request->ip();
//        if($queryIP != "127.0.0.1"){
////            $queryIP = "14.127.250.57";
//            $url = 'http://api.map.baidu.com/location/ip?ak=bEl6abgapRGZPbPKW1bzc8bHNlPqVAC6&ip='.$queryIP;//百度
//            $ch = curl_init($url);
//            curl_setopt($ch,CURLOPT_ENCODING ,'gb2312');
//            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
//            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; // 获取数据返回
//            $result = curl_exec($ch);
//            $result = mb_convert_encoding($result, "utf-8", "gb2312"); // 编码转换，否则乱码
//            //   print_r($result);
//            curl_close($ch);
//            $ipArray  = json_decode($result,true);
//            if($ipArray['status'] == 200){
//                $location = explode("|",$ipArray['address'])[0];
//                if($location != "CN" && $location != "cn"){
//                    header("location:".$this->request->domain()."/en");
//                    exit;
//                }
//            }
//        }
        header("location:".$this->request->domain()."/zh");die;
//        return $this->view->fetch();
    }

    public function news()
    {
        $newslist = [];
        return jsonp(['newslist' => $newslist, 'new' => count($newslist), 'url' => 'https://www.fastadmin.net?ref=news']);
    }

}
